package org.jeecg.modules.sso.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.shiro.authc.ShiroRealm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(tags="用户校验服务端")
@RestController
@RequestMapping("/api/sso")
public class SsoController {

    @Autowired
    @Lazy
    private ShiroRealm shiroRealm;

    @ApiOperation(value="checkUserToken", notes="checkUserToken")
    @PostMapping(value = "/checkUserToken")
    public LoginUser checkUserTokenIsEffect ( @RequestParam(name="token") String token ) throws AuthenticationException {
        log.info("SSO checkUserTokenIsEffect 被远程调用");
        return shiroRealm.checkUserTokenIsEffect(token);
    }
}
